* Clean up
clear all

/* Set working directory: please set your own
cd "~/Dropbox/JOP third submission/JOP replication/"
*/

* Open dataset

use 01_data/elections_ciutadella_more_years, clear

* Grouping 2003 and 2004 together
* Pre vs. post
reghdfe pp_voteshare post##ep if period3 != ., absorb(table_code_electionspecific) cluster(table_code_electionspecific)
est store prepost_period3

* Fixed effects for each period
reghdfe pp_voteshare post##ep i.period3 if period3 != ., absorb(table_code_electionspecific) cluster(table_code_electionspecific)
est store threeperiods_period3

* Grouping 2004 and 2007 together
* Pre vs. post
reghdfe pp_voteshare post##ep if period2 != ., absorb(table_code_electionspecific) cluster(table_code_electionspecific)
est store prepost_period2

* Fixed effects for each period
reghdfe pp_voteshare post##ep i.period2 if period2 != ., absorb(table_code_electionspecific) cluster(table_code_electionspecific)
est store threeperiods_period2

* Make table
esttab prepost_period3 threeperiods_period3 prepost_period2 threeperiods_period2 using 03_tables/tabled12.tex, tex se replace mtitles ("2003-2019" "2003-2019" "2004-2019" "2004-2015")  keep (1.post 1.post#1.ep 2.period2 3.period2 2.period3 3.period3) coeflabels (1.post#1.ep "Treatment (absence of booth)" ep "European election" 1.post "2019" 2.period2 "2009-11" 3.period2 "2014-15" 2.period3 "2009-11" 3.period3 "2014-15") star(* 0.10 ** 0.05 *** 0.01) addnotes("All models include voting station * election type fixed effects" "Standard errors are clustered by voting station * election type")
